// Pinger Program for PCMod (CLIENT)

PROG.PName = "PrinterSoft"
PROG.Author = "[GU]|ZLC|thomasfn"

PROG.NiceName = "Printer-Soft"

function PROG:BuildWindow( WindowName, Desktop, Object )
	
	DInterface:AddLabel( "lblStatus", Desktop, "Awaiting Command", 5, 25 )
	
	// DInterface:AddTextbox( "txtText", Desktop, "", 5, 50, Object:GetWide()-10, Object:GetTall-60)
	local pn = vgui.Create( "DTextEntry" )
	pn:SetParent( Object )
	pn:SetPos( 5, 50 )
	pn:SetSize( Object:GetWide()-10, Object:GetTall()-60 )
	pn:SetMultiline( true )
	self.txtText = pn
	
	local btn = DInterface:AddButton( "btnPrint", Desktop, "Print", Object:GetWide()-140, 25, 120, 20, function( self )
		local pn = C_PRO.txtText
		if (pn) then
			SendCommand( "print", pn:GetValue() )
		else
			local pn = self.TXT
			if (pn) then
				SendCommand( "print", pn:GetValue() )
			end
		end
	end )
	if (btn) then btn.TXT = self.txtText end
	
	DInterface:AddButton( "btnPrintTest", Desktop, "Test Page", Object:GetWide()-260, 25, 120, 20, function( self )
		SendCommand( "print", "#testpage" )
	end )
	
	DInterface:AddButton( "btnQuit", Desktop, "X", Object:GetWide()-20, 0, 20, 20, function() SendCommand( "quit" ); end )
end

function PROG:ClearWindow( Desktop )
	DInterface:RemoveLabel( "lblStatus", Desktop )

	DInterface:RemoveTextbox( "txtText", Desktop )
	DInterface:RemoveButton( "btnPrint", Desktop )
	DInterface:RemoveButton( "btnPrintTest", Desktop )
	
	if (self.txtText) then self.txtText:Remove() end
	
	DInterface:RemoveButton( "btnQuit", Desktop )
end

// Data[1] = Tag
// Data[2] = Content
function PROG:DataRecieved( Desktop, Data )
	if (Data[1] == "status") then DInterface:SetLabelText( "lblStatus", Desktop, Data[2] ) end
end

function PROG:Paint( x, y, w, h )
	// draw.SimpleText( self.NiceName, "SmallPCText", x + (w*0.05), y + (h*0.05), Color( 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
end